import React from "react";
import classes from "./logoutBtn.module.less";
import { useReactive } from "ahooks";
import classNames from "classnames";
import { useDispatch } from "react-redux";
import kingsInstance from "../../instance";
import { EVENT } from "../../enums";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
import { Fragment as _Fragment } from "react/jsx-runtime";
function LogoutBtn(props) {
    var logoutsure = function logoutsure() {
        dispatch.app.deleteUserInfo();
        dispatch.app.PUSH("/login");
        kingsInstance.emit(EVENT.close);
    };
    var state = useReactive({
        open: false
    });
    var dispatch = useDispatch();
    var logout = function() {
        state.open = false;
        logoutsure();
    };
    return /*#__PURE__*/ _jsxs(_Fragment, {
        children: [
            props.trigger && /*#__PURE__*/ React.cloneElement(props.trigger, {
                onClick: function(ev) {
                    var _props_trigger_props, _props_trigger_props_onClick, _props_trigger;
                    state.open = true;
                    (_props_trigger_props_onClick = _props_trigger_props = props === null || props === void 0 ? void 0 : (_props_trigger = props.trigger) === null || _props_trigger === void 0 ? void 0 : _props_trigger.props.onClick) === null || _props_trigger_props_onClick === void 0 ? void 0 : _props_trigger_props_onClick.call(_props_trigger_props, ev);
                }
            }),
            /*#__PURE__*/ _jsx("div", {
                children: /*#__PURE__*/ _jsx("div", {
                    children: /*#__PURE__*/ _jsxs("div", {
                        className: classes.passwordk2,
                        "v-show": "logoutshow",
                        children: [
                            /*#__PURE__*/ _jsx("img", {
                                src: require("../../assets/public/icon@2x.png"),
                                className: classes.maskclosepng2,
                                alt: "",
                                onClick: function(e) {
                                    e.stopPropagation();
                                    state.open = false;
                                }
                            }),
                            /*#__PURE__*/ _jsx("img", {
                                className: classes.passwordbg2,
                                src: require("../../assets/public/logoutbg.png")
                            }),
                            /*#__PURE__*/ _jsx("div", {
                                className: classes.passwordinfo2,
                                children: /*#__PURE__*/ _jsxs("div", {
                                    className: classNames("Montserrat-Bold font-12 ", classes.outsure),
                                    children: [
                                        " ",
                                        "Are you sure you want to LOG OUT?"
                                    ]
                                })
                            }),
                            /*#__PURE__*/ _jsx("div", {
                                className: classes.surebtn,
                                children: /*#__PURE__*/ _jsx("div", {
                                    className: "font-10",
                                    onClick: logout,
                                    children: "CONFIRM"
                                })
                            })
                        ]
                    })
                })
            })
        ]
    });
}
export default LogoutBtn;

 //# sourceMappingURL=index.js.map